package com.bwie.system.service.impl;

import com.bwie.common.domain.Type;
import com.bwie.system.mapper.TypeMapper;
import com.bwie.system.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className: TypeServiceImpl
 * @Description: TODO
 * @version: v1.８.0
 * @author:
 * @date:
 */
@Service
public class TypeServiceImpl implements TypeService {
    @Autowired
    private TypeMapper typeMapper;
    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public List<Type> typeList() {
        //获取分类数据
        Boolean b = redisTemplate.hasKey("type");
        if(!b){
            List<Type> types = typeMapper.typeList();
            redisTemplate.opsForValue().set("type",types);
        }
        List<Type> types = (List<Type>) redisTemplate.opsForValue().get("type");
        return types;
    }
}
